export function requestPromise(myUrl) {
  // 返回一个Promise实例对象
  return new Promise((resolve, reject) => {
    wx.request({
      url: myUrl,
      success: res => {
        if(res.statusCode == 200) resolve(res)
        else reject(res)
      },
      fail: res => reject(res)
    })
  })
}

export async function getUserInfo() {
  var userInfo = undefined
  await wx.getUserProfile({
    desc: '用于显示头像和姓名',
    lang:'zh_CN',
  }).then(res=>{ userInfo = res.userInfo })
  .catch(res=>{})
  if(userInfo == undefined) return;

  wx.cloud.callFunction({
    name: "uploadUserInfo",
    data: {userInfo}
  })
  return userInfo
}
